package com.qhong.modules.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.qhong.modules.entity.User;
import com.qhong.modules.service.IUserService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author qhong
 * @since 2018-07-25
 */
@RestController
@RequestMapping("/user")
public class UserController {
	@Autowired
	private IUserService userService;

	/**
	 * 分页 PAGE
	 */
	@GetMapping("/test")
	public Page<User> test() {
		return userService.selectPage(new Page<User>(0, 12));
	}

	@GetMapping("/SelectPrimaryKey")
	public Object SelectPrimaryKey(Integer id){
		User user=userService.selectByPrimaryKey(id);
		//System.out.println(JSON.toJSONString(user));
		return user;
	}

	@GetMapping("/deleteAll")
	public void deleteAll(){
		userService.deleteAll();
	}

	@GetMapping("/selectListBySQL")
	public Object selectListBySQL() throws InterruptedException {
		Thread.sleep(10000);
		List<User> list=userService.selectListBySQL();
		//System.out.println(JSON.toJSONString(list));
		return list;
	}
}
